<template>
  <div style="height:6vh;padding:10px 20px;background-color:#fff;">
    <span style="line-height:60px;font-size:20px;">停车记录</span>
  </div>
  <el-card style="margin: 20px;height: 70px;">
    <el-form :inline="true">
<!--      <el-form-item label="车辆id搜索" style="width: 220px;">-->
<!--        <el-input placeholder="请输入车辆id" v-model="searchParkRecord.carId" @keydown.enter="loadParkRecord"></el-input>-->
<!--      </el-form-item>-->
      <el-form-item label="使用时间搜索" style="width: 220px;">
        <el-input placeholder="请输入使用时间" v-model="searchParkRecord.parkingId" @keydown.enter="loadParkRecord"></el-input>
      </el-form-item>
      <el-form-item label="入场时间搜索" style="width: 220px;">
        <el-input placeholder="请输入入场时间" v-model="searchParkRecord.leaveTime" @keydown.enter="loadParkRecord"></el-input>
      </el-form-item>
      <el-form-item label="离开时间搜索" style="width: 220px;">
        <el-input placeholder="请输入离开时间" v-model="searchParkRecord.entranceTime" @keydown.enter="loadParkRecord"></el-input>
      </el-form-item>
      <el-form-item label="停车场名称搜索" style="width: 220px;">
        <el-input placeholder="请输入停车场名称" v-model="searchParkRecord.name" @keydown.enter="loadParkRecord"></el-input>
      </el-form-item>
<!--      <el-form-item label="停车场id搜索" style="width: 220px;">-->
<!--        <el-input placeholder="请输入停车场id" v-model="searchParkRecord.parkingId" @keydown.enter="loadParkRecord"></el-input>-->
<!--      </el-form-item>-->
    </el-form>
    <el-form-item>
      <el-button @click="resetSearch">重置</el-button>
      <el-button type="primary" @click="loadParkRecord">查询</el-button>
    </el-form-item>
  </el-card>
  <el-card style="margin:20px">
    <el-table :data="ParkRecordArr">
      <el-table-column  width="80" align="center" type="index" label="编号"></el-table-column>
<!--      <el-table-column align="center" prop="carId" label="车辆id"></el-table-column>-->
      <el-table-column align="center" prop="name" label="停车场名称"></el-table-column>
<!--      <el-table-column align="center" prop="parkingId" label="停车场id"></el-table-column>-->
      <el-table-column align="center" prop="userTime" label="停车时间（分钟）"></el-table-column>
      <el-table-column align="center" prop="entranceTime" label="入场时间"></el-table-column>
      <el-table-column align="center" prop="leaveTime" label="离场时间"></el-table-column>
    </el-table>
  </el-card>
</template>

<script setup>
import {onMounted, ref} from "vue";
import axios from "axios";
import qs, {parse} from "qs";
import {ElMessage} from "element-plus";

const searchParkRecord=ref({carId:'',name:'',parkingId:'',userTime:'',entranceTime:'',leaveTime:''})

const ParkRecordArr=ref([]);

const loadParkRecord=()=>{
  let data=qs.stringify(searchParkRecord.value);
  axios.get(BASE_URL+"/v1/parkrecord/select?"+data).then((response)=>{
    if (response.data.code==2000){
      ParkRecordArr.value=response.data.data;
    }else {
      ElMessage.error(response.data.msg);
    }
  })
}

onMounted(()=>{
  loadParkRecord();
})

const resetSearch = ()=>{
  //清空之前写的搜索条件
  searchParkRecord.value={};
  //重新加载所有的用户数据
  loadParkRecord();
}
</script>

<style scoped>

</style>